package com.xiaoye.digitaltwin.service.impl;

import com.xiaoye.digitaltwin.common.NullParameterException;
import com.xiaoye.digitaltwin.entity.Baopocontrol;
import com.xiaoye.digitaltwin.entity.dao.BaopoConfirm;
import com.xiaoye.digitaltwin.mapper.BaopocontrolMapper;
import com.xiaoye.digitaltwin.service.IBaopocontrolService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 爆破控制表 服务实现类
 * </p>
 *
 * @author xiaoye
 * @since 2023-08-19
 */
@Service
public class BaopocontrolServiceImpl extends ServiceImpl<BaopocontrolMapper, Baopocontrol> implements IBaopocontrolService {

    @Override
    public Baopocontrol check(BaopoConfirm baopoConfirm) {
        Double outerDiameter1 = baopoConfirm.getOuterDiameter1();
        Double outerDiameter2 = baopoConfirm.getOuterDiameter2();
        Double outerDiameter3 = baopoConfirm.getOuterDiameter3();
        Double wallThick1 = baopoConfirm.getWallThick1();
        Double wallThick2 = baopoConfirm.getWallThick2();
        Double wallThick3 = baopoConfirm.getWallThick3();

        if (outerDiameter1 == null){
            throw new NullParameterException("外径1值为空");
        }
        if (outerDiameter2 == null){
            throw new NullParameterException("外径2值为空");
        }
        if (outerDiameter3 == null){
            throw new NullParameterException("外径3值为空");
        }
        if(wallThick1 == null){
            throw new NullParameterException("壁厚1值为空");
        }
        if(wallThick2 == null){
            throw new NullParameterException("壁厚1值为空");
        }
        if(wallThick3 == null){
            throw new NullParameterException("壁厚1值为空");
        }


        //这里还可以进行数据校验，判断数据是否在正常范围


        Baopocontrol baopocontrol = new Baopocontrol();
        baopocontrol.setOuterDiameter1(outerDiameter1);
        baopocontrol.setOuterDiameter2(outerDiameter2);
        baopocontrol.setOuterDiameter3(outerDiameter3);
        baopocontrol.setWallThick1(wallThick1);
        baopocontrol.setWallThick2(wallThick2);
        baopocontrol.setWallThick3(wallThick3);
        return baopocontrol;
    }
}
